

import React, { Component } from 'react'
import {withRouter} from "../../HOC/hoc";

class Son extends Component {

    constructor(props){
        super(props);
        this.state = {
            result:[
                {
                    id:"01001",
                    name:"张三疯",
                    age:20
                }
            ]
        }
        console.log("子：constructor");
    }

    fn=()=>{
        console.log("this.props.name",this.props.name)
        console.log("this.props.minAge",this.props.minAge)
    }

    toParent=()=>{
        this.props.chuan(this.state.result);
    }
    componentWillMount(){
      console.log("子：componentWillMount");

    }

    componentDidMount(){
      console.log("子：componentDidMount");

    }

 
  render() {
    console.log("子：render");    
    const {name,minAge} = this.props;
    return (
      <div>
        <h1>子组件组件</h1>
        <p>查询条件name:{name}</p>
        <p>查询条件minAge:{minAge}</p>
        <input type="button" value="得到父组件传来的数据" onClick={this.fn} />
        <br/>
        <input type="button" value="把结果传给父组件" onClick={this.toParent} />

      </div>
    )
  }
}


export default withRouter(Son);